package com.atues.utils;

import java.util.Arrays;
import java.util.List;

public class ImageTypeChecker {

    private static final List<String> IMAGE_EXTENSIONS = Arrays.asList("jpg", "jpeg", "png", "gif", "bmp", "tiff", "webp");

    public static String getFileExtension(String fileName) {
        if (fileName.lastIndexOf(".") != -1) {
            return fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
        } else {
            return "";
        }
    }

    public static boolean isImage(String fileName) {
        String extension = getFileExtension(fileName);
        return IMAGE_EXTENSIONS.contains(extension);
    }

    public static void main(String[] args) {
        System.out.println(isImage("example.jpg")); // true
        System.out.println(isImage("example.txt")); // false
    }
}
